package com.welkom.everydate.domain;

import java.util.ArrayList;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;

import com.welkom.everydate.util.web.Header;

public class Authority implements GrantedAuthority{
	@Header(headerText="权限编号")
	private long authorityId;
	@Header(headerText="权限名称")
	private String authorityName;
	private String authorityDesc;
	@Header(headerText="权限状态")
	private int authorityEnabled;
	private int authorityLevel;
	private long parentId;
	private int hashChild;
	private List<Resource> resources=new ArrayList<Resource>();
	public Authority(long authorityId, String authorityName,
			String authorityDesc, int authorityEnabled) {
		this.authorityId = authorityId;
		this.authorityName = authorityName;
		this.authorityDesc = authorityDesc;
		this.authorityEnabled = authorityEnabled;
	}
	public Authority() {
		
	}
	/**
	 * @return the authorityId
	 */
	public long getAuthorityId() {
		return authorityId;
	}
	/**
	 * @param authorityId the authorityId to set
	 */
	public void setAuthorityId(long authorityId) {
		this.authorityId = authorityId;
	}
	/**
	 * @return the authorityName
	 */
	public String getAuthorityName() {
		return authorityName;
	}
	/**
	 * @param authorityName the authorityName to set
	 */
	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}
	/**
	 * @return the authorityDesc
	 */
	public String getAuthorityDesc() {
		return authorityDesc;
	}
	/**
	 * @param authorityDesc the authorityDesc to set
	 */
	public void setAuthorityDesc(String authorityDesc) {
		this.authorityDesc = authorityDesc;
	}
	/**
	 * @return the authorityEnabled
	 */
	public int getAuthorityEnabled() {
		return authorityEnabled;
	}
	/**
	 * @param authorityEnabled the authorityEnabled to set
	 */
	public void setAuthorityEnabled(int authorityEnabled) {
		this.authorityEnabled = authorityEnabled;
	}
	/**
	 * @return the resources
	 */
	public List<Resource> getResources() {
		return resources;
	}
	/**
	 * @param resources the resources to set
	 */
	public void setResources(List<Resource> resources) {
		this.resources = resources;
	}
	public String getAuthority() {
		// TODO Auto-generated method stub
		return this.authorityName;
	}
	
	@Override
	public boolean equals(Object object){
		if(!(object instanceof Authority)){
			return false;
		}
		Authority authority=(Authority)object;
		if(!(authority.getAuthorityId()==this.getAuthorityId())){
			return false;
		}
		if(!(authority.getAuthorityName().equals(this.authorityName))){
			return false;
		}
		return true;
	}
	
	@Override
	public int hashCode(){
		int result=17;
		result=31*result+(int)(authorityId^(authorityId>>>32));
		result=31*result+this.getAuthorityName().hashCode();
		return result;
	}
	
	public int getAuthorityLevel() {
		return authorityLevel;
	}
	public void setAuthorityLevel(int authorityLevel) {
		this.authorityLevel = authorityLevel;
	}
	public long getParentId() {
		return parentId;
	}
	public void setParentId(long parentId) {
		this.parentId = parentId;
	}
	public int getHashChild() {
		return hashChild;
	}
	public void setHashChild(int hashChild) {
		this.hashChild = hashChild;
	}
	
	
}
